package
{
	import flash.geom.Point;
	
	public class BubbleModel
	{
		public function BubbleModel()
		{
		}
		
		private static var _instance:BubbleModel;
		
		public static function get instance():BubbleModel {
			if(_instance == null){
				_instance = new BubbleModel();
			}
			return _instance;
		}
		
		public var deletedToBubbles:Array;// 准备要删除的
		
		public var checkedToBubbles:Array;// 已经检测过的
		
		public function addCheckedToBubbles(position:Point):void {
			this.checkedToBubbles.push(position);
		}
		
		public function hasObjectInCheckedToBubbles(toCompare:Point):Boolean {
			for(var i:int = 0; i < checkedToBubbles.length; i++){
				var position:Point = checkedToBubbles[i];
				if(position.equals(toCompare)){
					return true;
				}
			}
			return false;
		}
		
		public function get canRemove():Boolean {
			return this.deletedToBubbles.length >= 3;
		}
		
		public function initialize():void {
			deletedToBubbles = [];
			checkedToBubbles = [];
		}
		
		private var _items:Array = [];
		
		public function setItem(yIndex:int,xIndex:int,item:*):void {
			this.items[yIndex][xIndex] = item;
		}
		
		public function getItem(yIndex:int,xIndex:int):* {
			if(this.items[yIndex]){
				return this.items[yIndex][xIndex];
			}
			return null;
		}
		
		public function get items():Array {
			return this._items;
		}
		
	}
}